import 'dart:io';
import 'package:android_id/android_id.dart';
import 'package:device_info_plus/device_info_plus.dart';

class DeviceUtils {
  Future<String?> getId() async {
    var deviceInfo = DeviceInfoPlugin();

    if (Platform.isIOS) {
      var iosDeviceInfo = await deviceInfo.iosInfo;
      return iosDeviceInfo.identifierForVendor;
    } else if (Platform.isAndroid) {
      final androidId = await const AndroidId().getId();
      return androidId;
    } else if (Platform.isWindows) {
      var windowsDeviceInfo = await deviceInfo.windowsInfo;
      return windowsDeviceInfo.deviceId;
    } else if (Platform.isMacOS) {
      var macosDeviceInfo = await deviceInfo.macOsInfo;
      return macosDeviceInfo.systemGUID ?? macosDeviceInfo.model;
    } else if (Platform.isLinux) {
      var linuxDeviceInfo = await deviceInfo.linuxInfo;
      return linuxDeviceInfo.name;
    }

    return null;
  }
}
